import os

# 定义需要修改的文件类型和前缀
file_type = ".doc"
prefix = "DOC_"

# 定义工作文件夹路径
work_dir = r"D:\JX\2022北京\OFFICE"

# 遍历工作文件夹，查找并修改文件名
for root, dirs, files in os.walk(work_dir):
    for file in files:
        if file.endswith(file_type):
            file_path = os.path.join(root, file)
            new_file_name = prefix + file
            new_file_path = os.path.join(root, new_file_name)
            os.rename(file_path, new_file_path)
            print(f"File {file} renamed to {new_file_name}")
